const Koa=require('koa'),
 router=require('koa-router')(),
 logger=require('koa-logger'),
 bodyparser=require('koa-bodyparser');
const auth=require('./server/routes/auth.js');//引入路由文件auth.js
const api=require('./server/routes/api.js');
const jwt=require('koa-jwt');
const cors = require('koa2-cors');//跨域模块
const app=new Koa()
app.use(bodyparser());
app.use(logger())
app.on('error',function(err,ctx){
	console.log('server error: ',err);
})
//app.use(cors());//跨域模块
router.use('/auth',auth.routes());//挂载到koa-router上，同时让所有auth的请求路径前都加、auth
router.use('/api',api.routes());
app.use(router.routes(),bodyparser());//将路由规则挂载到koa上
app.listen(8889,() => {
  console.log('Koa is listening in 8889');
});
module.exports=app;